#ifndef _MT5_ANIMATIN_H_
#define _MT5_ANIMATIN_H_

#include "mat_define.h"
#include "math/vec2.h"
#include "graphics/color.h"

#include <vector>

namespace ui
{
	class UISprite;
}


struct MATGem;

class MATAniFinishEventReceiveable;


class MATAnimation	
{
public:

	enum ANI_TYPE
	{
		ANI_TYPE_SMALLTOBIG,	
		ANI_TYPE_MATCHED,
		ANI_TYPE_MOVING,

		ANI_TYPE_C,
	};

	MATAnimation();
	~MATAnimation();
	
	virtual void		Init(int y, int x, MATGem* pGemType);
	virtual void		Tick(float dt);
	virtual void		GetInfos(math::Vec2& Pos, math::Vec2& Size,COLOR& c, float& Rotation) = 0;
	
	
	ANI_TYPE			GetType() const { return m_Type; };

	bool				IsFinish() const { return m_IsFinish; };
	MATGem*				GetGemType() { return m_pGemType; };
	int					GetX() const { return m_X; };
	int					GetY() const { return m_Y; };

	void				ForceFinish(); 	
	void				SetCallBack(MATAniFinishEventReceiveable* pCallBackObj) { m_pFinishEventReceiveable = pCallBackObj; };
	

protected:

	int									m_X;
	int									m_Y;



	bool										m_IsFinish;
	ANI_TYPE									m_Type;
	MATGem* 									m_pGemType;

	MATAniFinishEventReceiveable*				m_pFinishEventReceiveable;
	
};

class MATAniFinishEventReceiveable
{
public: 
	virtual void	OnAnimationFinish(MATAnimation::ANI_TYPE AnimationType) = 0;
};

class MATAniSmallTobig	: public MATAnimation
{
public:

	MATAniSmallTobig();
	
	
	virtual void		Init(int y, int x, MATGem* pGemTyp);
	virtual void		Tick(float dt);
	virtual void		GetInfos(math::Vec2& Pos, math::Vec2& Size,COLOR& c, float& Rotation);
	void				SetToMakeLogicallyBig(bool b);
	

protected:

	float				m_Scale;
	bool				m_ToMakeLogicallyBig;
	
};


class MATAniMatched	: public MATAnimation
{
public:

	MATAniMatched();


	enum				ANIMATCH_STATE
	{
		ANIMATCH_STATE_GLOW,
		ANIMATCH_STATE_COLLECT,

		ANIMATCH_STATE_C,
	};
	
	
	virtual void		Init(int y, int x, MATGem* pGemTyp);
	virtual void		Tick(float dt);
	virtual void		GetInfos(math::Vec2& Pos, math::Vec2& Size,COLOR& c, float& Rotation);
	

protected:

	float				m_AlphaPercent;

	
};


class MATAniMoving: public MATAnimation
{
public:

	MATAniMoving();


	enum				ANIMATCH_STATE
	{
		ANIMATCH_STATE_GLOW,
		ANIMATCH_STATE_COLLECT,

		ANIMATCH_STATE_C,
	};
	
	
	virtual void				Init(int y, int x, MATGem* pGemTyp);
	virtual void				Tick(float dt);
	virtual void				GetInfos(math::Vec2& Pos, math::Vec2& Size,COLOR& c, float& Rotation);
	void						AddMovePosition(const math::Vec2& Pos);
	void						ClearPositions();
	void						ToRotate(bool b);
	int							GetMoveIndex() const { return m_MoveIndex; };
	void						SetShouldAccelerate(bool b) { m_ShouldAccelerate  = b; };

protected:

	math::Vec2					m_Pos;
	math::Vec2					m_PosTarget;
	std::vector<math::Vec2>		m_MovePositions;
	int							m_MoveIndex;
	math::Vec2					m_Dir;
	bool						m_ToRotate;
	int							m_RotateDir;
	float						m_Rotation;
	bool						m_ShouldAccelerate;
	float						m_Acceleration;
	
};

#endif	// _MT5_ANIMATIN_H_